/*
This file is part of Docking@Home.
http://docking.gcl.cis.udel.edu
Copyright (C) 2009 University of Delaware

Docking@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Docking@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Docking@Home.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Filename: TabWindow.cpp
	Description: Contains information about where on the screen a tab can
		render the information it is supposed to contains. 
	Revision History: 
		Created - 01/03/08
	Author: Robert Keller (01/03/08 -> current)
*/

#include "TabWindow.h"

// ------------------------------------------------------------
// Static Declarations
// ------------------------------------------------------------

GLHelper * TabWindow::glHelper;

// ------------------------------------------------------------
// Constructor / Destructor
// ------------------------------------------------------------

TabWindow::TabWindow ()
	: PADDING_LEFT(20),
	  PADDING_RIGHT(20),
	  PADDING_TOP(30),
	  PADDING_BOTTOM(30),
	  STANDARD_WIDTH(600),
	  STANDARD_HEIGHT(400)
{
	windowWidth = 0;
	windowHeight = 0;

	logoOffset = 0;

	topLeftX = 0;
	topLeftY = 0;

}// TabWindow

TabWindow::~TabWindow ()
{
}// ~TabWindow

// ------------------------------------------------------------
// Member Modifiers
// ------------------------------------------------------------

void TabWindow::setWindowWidth (int w)
{
	windowWidth = w;
	widthFactor = w / (float)STANDARD_WIDTH;
}// setWindowWidth

void TabWindow::setWindowHeight (int h)
{
	windowHeight = h;
	heightFactor = h / (float)STANDARD_HEIGHT;
}// setWindowHeight

void TabWindow::setLogoOffset (int h)
{
	logoOffset = h;
}// setLogoHeight

void TabWindow::resetCorners ()
{
	topLeftX = PADDING_LEFT;
	topLeftY = logoOffset + (int)(PADDING_TOP * heightFactor);

	bottomRightX = windowWidth - PADDING_RIGHT;
	bottomRightY = windowHeight - PADDING_BOTTOM;

	middleX = (topLeftX + bottomRightX) / 2;

}// resetTopLeft

void TabWindow::setBorderColor (const float color[4])
{
	glHelper->copyColor4f(borderColor, color);
}// setBorderColor

// ------------------------------------------------------------
// Member Accessors
// ------------------------------------------------------------

int TabWindow::getWindowWidth () const 
{
	return windowWidth;
}// getWindowWidth

int TabWindow::getWindowHeight () const
{
	return windowHeight;
}// getWindowHeight

int TabWindow::getTopLeftX () const
{
	return topLeftX;
}// getTopLeftX

int TabWindow::getTopLeftY () const
{
	return topLeftY;
}// getTopLeftY

int TabWindow::getBottomRightX () const
{
	return bottomRightX;
}// getBottomRightX

int TabWindow::getBottomRightY () const
{
	return bottomRightY;
}// getBottomRightY

int TabWindow::getMiddleX () const
{
	return middleX;
}// getMiddleX

float TabWindow::getHeightFactor () const
{
	return heightFactor;
}// getHeightFactor

float TabWindow::getWidthFactor () const
{
	return widthFactor;
}// getWidthFactor

// ------------------------------------------------------------
// Render Functions
// ------------------------------------------------------------

// Displays the bounds of the window 
void TabWindow::draw ()
{
	glHelper->drawRect((float)topLeftX, (float)topLeftY, 
		(float)bottomRightX, (float)bottomRightY, borderColor);
}// draw
